<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">添加角色</h4>
</div>
<form id="defaultForm" method="post" class="form-horizontal" action="/system/user_save">
    <div class="modal-body">

        <div class="form-group">
            <label class="col-lg-3 control-label">用户名</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="loginName" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">登录密码</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="password" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">真实姓名</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="name" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">性别</label>
            <div class="col-lg-5">
                <select class="form-control" name="sex">
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">手机号</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="telephone" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">电话</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="mobile" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">email</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="email" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">角色</label>
            <div class="col-lg-5">
                <select class="form-control" name="role">
                    <option value="">选择角色</option>
                    <option th:each="role:${roles}" th:value="${role.id}" th:text="${role.name}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">客户公司</label>
            <div class="col-lg-5">
                <select class="form-control" name="customer">
                    <option value="">选择公司</option>
                    <option th:each="customer:${customers}" th:value="${customer.id}" th:text="${customer.name}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">公司职务</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="jobTitle" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">简介</label>
            <div class="col-lg-5">
                <input type="text" class="form-control" name="remark" />
            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>

<script>
    //表单初始化
    initCheck();
    //添加验证
    $("#defaultForm").bootstrapValidator('addField','telephone',{
        validators: {
            notEmpty: {
                message: '手机不能为空'
            },
            stringLength: {
                min: 11,
                max: 11,
                message: '手机号码只能是11个字符'
            },
            regexp: {
                regexp: /^1[3|4|5|8][0-9]\d{4,8}$/,
                message: '不是正确的手机格式'
            }
        }
    });
    $("#defaultForm").bootstrapValidator('addField','role',{
        validators: {
            notEmpty: {
                message: '角色不能为空'
            }
        }
    });

    $("#defaultForm").bootstrapValidator('addField','customer',{
        validators: {
            notEmpty: {
                message: '公司不能为空'
            }
        }
    });

</script>